package com.example.mvp.im.observr

import com.example.inter.NetWorkInterface
import java.util.*

/**
 * @author  chaohaipeng  on 2018/8/22.
 */
class NetObsver : Observer {
    /**
     * 更新接口
     *
     * @param updateDataInterface
     */
    private var netWorkInterface: NetWorkInterface?=null

    fun setNetWorkInterfaceListener(netWorkInterface: NetWorkInterface) {
        this.netWorkInterface = netWorkInterface
    }

    /**
     * 加载页面逻辑
     */
    fun start() {
        //注册消息监听
        NetObservable.getInstance().addObserver(this)
    }
    /**
     * 中止页面逻辑
     */
    fun stopMessagePresenter() {
        //注销消息监听
        NetObservable.getInstance().deleteObserver(this)
    }
    override fun update(observable: Observable, o: Any?) {
        if (o != null && o is Int) {
            netWorkInterface?.onConnected(o)
        }
    }
}